import request from "@/utils/request";
/**
 * 获取所有角色列表
 * @param {*} page
 * @param {*} pagesize
 * @returns
 */
export const getUerRoleAPI = (query) => {
  return request({
    method: "get",
    url: "/sys/role",
    params: query,
  });
};

/**
 * 删除角色
 * @param {String} roleId
 * @returns  Promise
 */
export const delRoleAPI = (roleId) => {
  return request({
    method: "delete",
    url: `/sys/role/${roleId}`,
  });
};

/**
 * 添加角色
 * @param {*} name
 * @param {*} region
 * @returns Objeck
 */
export const AddRoleAPI = (data) => {
  return request({
    method: "post",
    url: "/sys/role",
    data,
  });
};

/**
 *
 * @param {Sring} rowId
 * @returns promise
 */
export const getRoleDetailAPI = (roleId) => {
  return request({
    method: "get",
    url: `/sys/role/${roleId}`,
  });
};

/**
 * 编辑角色
 * @param {Object} form
 * @returns promise
 */
export const editRoleAPI = (form) => {
  return request({
    method: "put",
    url: `/sys/role/${form.id}`,
    data: form,
  });
};

/**
 * 获取公司详情
 * @param {Sring} comanyId
 * @returns promise
 */
export const getCompanyDetailAPI = (comanyId) => {
  return request({
    method: "get",
    url: `/company/${comanyId}`,
  });
};

/**
 * 给角色分配权限
 * @param {String} id
 * @param {Array} permIds
 * @returns Promise
 */
export const assignPermAPI = (id, permIds) => {
  return request({
    method: "put",
    url: `/sys/role/assignPrem`,
    data: {
      id,
      permIds,
    },
  });
};
